package com.rookie.jeesdp.controller;

import com.rookie.jeesdp.annotation.CheckPermissions;
import com.rookie.jeesdp.entity.admin.LoginUser;
import com.rookie.jeesdp.utils.UserUtils;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
public class UserController {

    @RequestMapping("/admin")
    @CheckPermissions("admin:demo")
    public LoginUser admin(HttpSession session) {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return UserUtils.getLoginUser();
    }
}
